package com.xuyuli.dao;

import com.xuyuli.domain.User;
import com.xuyuli.service.UserService;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;

@Component
@Aspect
public class Aop {
    @Autowired
    UserService userService;
    //登录
    @AfterReturning(value = "execution (* com.xuyuli.controller.UserController.loginCheck(..))",returning = "result")
    public void afterlogin( Object result){
        User user = (User) ((ModelAndView)result).getModel().get("user");
        if (user!=null){
            userService.loginSuccess(user);
        }else {
            System.out.println("w");
        }
//        userService.loginSuccess(user);
    }

}
